package com.acwebsitedesign.uRateDrugs.domain;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( { "/spring-service.xml" } )
public class UserServiceTestIntegration {

	
	@Autowired
	AccountService accountService;
	
	@Test 
	public void saveNewUser(){
		String test = "test";
		Account account = new Account();
		account.setUsername(test);
		account.setPassword(test);
		account.setEmail(test);
		account.setAgreeToTerms(test);
		account.setGender(true);
		account.setZip(12345);
		account.setAge(34);
		accountService.save(account);
	}
	
	@Test
	public void getUserById(){
		String username = "test";
		Account account = accountService.getUserByUsername(username);
		int id = account.getId();
		@SuppressWarnings("unused")
		Account user2 = accountService.getUserById(id);
		System.out.println("Users name is " + account.getUsername());
	}
	

	@Test
	public void removeUserByUsername(){
		accountService.removeUserByName("test");
	}
}
